package com.example.component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fongjx on 2021/6/25.
 */
public class Folder extends Root{

    List<Root> folders = new ArrayList<>();

    public Folder(String name){
        super(name);
    }

    public List<Root> getFolders() {
        return folders;
    }

    public void setFolders(List<Root> folders) {
        this.folders = folders;
    }

    @Override
    void addFile(Root root) {
        folders.add(root);
    }

    @Override
    void removeFile(Root root) {
        folders.remove(root);
    }

    @Override
    void display(int depth) {
        final StringBuilder stringBuilder = new StringBuilder();
        for(int i = 0; i < depth; i++){
            stringBuilder.append("--");
        }
        System.out.println(stringBuilder.toString() + this.getName());
        for (Root folder : folders) {
            System.out.println(folder.getName());
        }
    }
}
